package com.example.controller;

import com.example.model.vo.TypeVO;
import com.example.impl.GoodTypeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Controller
@RequestMapping("type")
public class TypeController {

    @Autowired
    private GoodTypeServiceImpl goodTypeService;

    @RequestMapping("/list")
    @ResponseBody
    public List list(){
        List<TypeVO> typeVOS =goodTypeService.listTypes();
        HashMap<String,Object> tree = new HashMap<>();
        tree.put("text","商品类别列表");
        tree.put("nodes",typeVOS);
        List list = new ArrayList();
        list.add(tree);
        return list;
    }
}

